
console.log("content")
let dc = document
var iframeDocument = document.getElementsByTagName('iframe')[0].contentDocument;
console.log(iframeDocument)
chrome.runtime.onMessage.addListener(
    function (request, sender, sendResponse) {

        switch (request.greeting) {
            case "hello": {
                if (dc !== undefined) {
                    // alert(dc.designMode)
                    dc.designMode = "on"
                    !function () { var t = function (t) { t.stopPropagation(), t.stopImmediatePropagation && t.stopImmediatePropagation() };["copy", "cut", "contextmenu", "selectstart", "mousedown", "mouseup", "keydown", "keypress", "keyup"].forEach(function (e) { document.documentElement.addEventListener(e, t, { capture: !0 }) }) }();
                    sendResponse({ code: 1, result: dc });
                } else {
                    sendResponse({ code: 0, message: "无法获取document对象" });
                }
                break;
            }
            case "study": {
                let vd = iframeDocument?.querySelector("video");
                console.log(vd)
                if (vd !== undefined && vd !== null) {
                    vd.currentTime = 550
                    sendResponse({ code: 1, result: vd });
                } else {
                    sendResponse({ code: 0, result: vd, message: "请先播放视频，再点击按钮！" });
                }
                break;
            }
            default:
                alert("错误！");
                break;

        }


    });